package com.teach.shape4;

import java.util.Scanner;

/**
 * 椭圆
 * @author J.L.Zhou
 *	jlzhou.top 版权所有
 */
public class Ellipse extends AbstractShape {

	/**
	 * 宽
	 */
	private float a;
	/**
	 * 高
	 */
	private float b;
	
	public Ellipse(){
		super.name = "椭圆";
	}
	
	public void input(Scanner sc) {
		System.out.println("输入"+name+"的最长半径: ");
		a = sc.nextFloat();

		System.out.println("输入"+name+"的最短半径: ");
		b = sc.nextFloat();
	}
	
	public float getA() {
		return a;
	}


	public void setA(float a) {
		this.a = a;
	}


	public float getB() {
		return b;
	}


	public void setB(float b) {
		this.b = b;
	}

	@Override
	public void calculate() {
		if(b>a){
			float temp = a;
			a = b;
			b = temp;
		}
		
		perimeter = (float)(2*Math.PI*b+4*(a-b));
		area = (float)(Math.PI*a*b);
	}

	@Override
	public String getInputInfo() {
		return String.format("半径：%.2f,%.2f", a,b);
	}

}
